#include "StdAfx.h"
#include "ThreadsPool.h"
#include <windows.h>
#include <process.h>


#include <iostream>
#include <algorithm>
using namespace std;

CThreadsPool::CThreadsPool(void)
{
}


CThreadsPool::~CThreadsPool(void)
{
	for_each( m_ThreadHandleList.begin() , m_ThreadHandleList.end() , [](HANDLE handle)->void
	{
		CloseHandle(handle);
	});
}



void CThreadsPool::BeginThread(unsigned WINAPI ThreadFunc(void* arg), void* pArg)
{
    HANDLE handle = (HANDLE)_beginthreadex(nullptr, 0, ThreadFunc, pArg, 0, nullptr);

	m_ThreadHandleList.push_back(handle);
}
